package dao;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class UserDAOTestor2 {


     @Test
    public  void  testSelect() throws IOException {

        InputStream inputStrem = Resources.getResourceAsStream("mybatis.cf.xml");

        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStrem);

        SqlSession sqlSession = sqlSessionFactory.openSession(true);

        String statement = "org.zsl.dao.UserDAO.select";

        List<org.zsl.model.User> userList=  sqlSession.selectList(statement);

         System.out.println(userList);

        for (org.zsl.model.User user : userList){
            System.out.println(user.getUsername());
        }
    }


    @Test
    public  void testInsert() throws IOException {



    }
}
